package com.maiji.cloud.entities.shopingmall;

import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableLogic;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.Date;
import java.util.Objects;

/**
 *  订单表
 */
@NoArgsConstructor
@Data
@Accessors(chain=true)
@Table(name = "shoping_order")
public class ShopingOrder {

    @TableId
    @Column(name = "uu_id", type = MySqlTypeConstant.VARCHAR, length = 50, isKey = true)
    private String uuId;

    @Column(name = "user_id", type = MySqlTypeConstant.VARCHAR, length = 50)
    private String userId; // 用户ID

    @Column(name = "order_no", type = MySqlTypeConstant.VARCHAR, length = 50, isUnique = true)
    private String orderNo; // 订单编号

    @Column(name = "delivery", type = MySqlTypeConstant.VARCHAR, length = 50)
    private String delivery; // 配送方式

    @Column(name = "delivery_fee", type = MySqlTypeConstant.DOUBLE, length = 5, decimalLength = 2)
    private Double deliveryFee;  // 配送费

    @Column(name = "weight_total", type = MySqlTypeConstant.INT, length = 2)
    private Integer weightTotal; // 商品总重（克）

    @Column(name = "remarks", type = MySqlTypeConstant.VARCHAR)
    private String remarks; // 买家备注

    @Column(name = "seller_remarks", type = MySqlTypeConstant.VARCHAR)
    private String sellerRemarks; // 卖家备注

    @Column(name = "fund", type = MySqlTypeConstant.DOUBLE, length = 5, decimalLength = 2, defaultValue = "0.00")
    private Double fund;  // 使用减肥基金

    @Column(name = "integral", type = MySqlTypeConstant.INT, length = 2, defaultValue = "0")
    private Integer integral; // 使用的积分值

    @Column(name = "integral_money", type = MySqlTypeConstant.DOUBLE, length = 5, decimalLength = 2, defaultValue = "0.00")
    private Double integralMoney; // 使用积分兑换购物金额

    @Column(name = "exchange_id", type = MySqlTypeConstant.VARCHAR, length = 50)
    private String exchangeId; // 优惠券ID

    @Column(name = "coupon", type = MySqlTypeConstant.DOUBLE, length = 5, decimalLength = 2, defaultValue = "0.00")
    private Double coupon;  // 优惠券金额

    @Column(name = "amount", type = MySqlTypeConstant.DOUBLE, length = 5, decimalLength = 2)
    private Double amount;  // 订单金额

    @Column(name = "pay_type", type = MySqlTypeConstant.INT, length = 1)
    private Integer payType; //支付方式：0-砍价免费拿，1-余额支付，2-微信支付 ，3-支付宝支付，4，积分兑换

    @Column(name = "prepay_id", type = MySqlTypeConstant.VARCHAR, length = 120)
    private String prepayId; // 支付预支付交易单号

    @Column(name = "out_trade_no", type = MySqlTypeConstant.VARCHAR, length = 120)
    private String outTradeNo; // 微信支付商家单号-流水号

    @Column(name = "pay_id", type = MySqlTypeConstant.VARCHAR, length = 120)
    private String payId; // 支付交易号：支付成功返回的交易单号

    @Column(name = "create_date", type = MySqlTypeConstant.DATETIME)
    private Date createDate; // 创建订单时间

    @Column(name = "pay_date", type = MySqlTypeConstant.DATETIME)
    private Date payDate; // 支付时间

    @Column(name = "send_date", type = MySqlTypeConstant.DATETIME)
    private Date sendDate; // 发货时间

    @Column(name = "auto_receive", type = MySqlTypeConstant.BIT, length = 1)
    private Boolean autoReceive; // 是否为自动收货

    @Column(name = "receive_date", type = MySqlTypeConstant.DATETIME)
    private Date receiveDate; // 确认收货时间

    @Column(name = "done_date", type = MySqlTypeConstant.DATETIME)
    private Date doneDate; // 完成订单时间

    @Column(name = "cancel_date", type = MySqlTypeConstant.DATETIME)
    private Date cancelDate; // 取消时间

    @Column(name = "cancel_reason", type = MySqlTypeConstant.VARCHAR, length = 50)
    private String cancelReason; // 取消原因

    @Column(name = "shoping_address_id", type = MySqlTypeConstant.VARCHAR, length = 50)
    private String shopingAddressId; // 收货地址ID

    @Column(name = "remind_send", type = MySqlTypeConstant.BIT)
    private Boolean remindSend; // 提醒发货

    @Column(name = "printed", type = MySqlTypeConstant.BIT)
    private Boolean printed; // 是否打印快递单

    @Column(name = "print_date", type = MySqlTypeConstant.DATETIME)
    private Date printDate; // 打印时间

    @Column(name = "commission", type = MySqlTypeConstant.BIT)
    private Boolean commission; // 是否产生佣金

    @Column(name = "share_order", type = MySqlTypeConstant.BIT )
    private Boolean shareOrder; // 是否结算订单返现

    @Column(name = "share_order_money", type = MySqlTypeConstant.DOUBLE, length = 5, decimalLength = 2, defaultValue = "0.00")
    private Double shareOrderMoney; // 订单返现

    @Column(name = "status", type = MySqlTypeConstant.INT, length = 1, defaultValue = "0")
    private Integer status; // 订单状态：0-待付款, 1-待发货，2-待收货，3-已收货/待评价，4-已取消，5-已评价，6-订单完成

    @Column(name = "refund_status", type = MySqlTypeConstant.INT, length = 1, defaultValue = "-1")
    private Integer refundStatus; // 退款状态，-1未申请退款或已撤销退款，0申请退款，1同意，2待退款，3退款中，4退款成功，5拒绝

    @Column(name = "refund_date", type = MySqlTypeConstant.DATETIME)
    private Date refundDate; // 申请退款时间
    
    @Column(name = "nonce_str", type = MySqlTypeConstant.VARCHAR, length = 50)
    private String nonceStr; // 预支付时的随机字符串，用于支付成功时的校验

    @TableLogic
    @Column(name = "is_del", type = MySqlTypeConstant.INT, length = 1, defaultValue = "0")
    private Integer isDel; // 是否逻辑删除，1是，0否

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ShopingOrder that = (ShopingOrder) o;
        return uuId.equals(that.uuId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(uuId);
    }

}
